package kr.pe.osdev.web;

import kr.pe.osdev.domain.Category;
import kr.pe.osdev.domain.User;
import kr.pe.osdev.service.AuthorityService;
import kr.pe.osdev.service.CategoryService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.wrapper.SavedRequestAwareWrapper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.context.request.WebRequest;

@Controller
public class CategoryController {
	@Autowired
	CategoryService categoryService;

	@RequestMapping(value = { "/category/list.html" }, method = RequestMethod.GET)
    public ModelMap list(ModelMap model, SavedRequestAwareWrapper request, WebRequest request2) {
        User user = AuthorityService.getUser(request.getSession());
        Category category = new Category();
        category.setUserSid(user.getSid());
        category.setCategoryType("Q00901");
        
        model.addAttribute("list", categoryService.findListByUserSid(category));
        
        return model;
    }
}